package com.basic.bio.chat.groupchatdemo;

import java.io.IOException;
import java.io.PrintStream;
import java.net.Socket;
import java.util.Scanner;

/**
 * @Description:服务器端
 * @Author:Zc9741
 * @QQ:516906531
 */
public class ClientSendRunnable implements Runnable{

    private Socket socket;

    public ClientSendRunnable(Socket socket) {
        this.socket = socket;
    }


    @Override
    public void run() {
        System.out.println("客户端开始发消息咯。。。");
        Scanner sc= null;
        PrintStream ps=null;
        try {
            sc=new Scanner(System.in);
            ps=new PrintStream(socket.getOutputStream());
            while (sc.hasNext()){
                ps.println(sc.nextLine());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            sc.close();
            ps.close();
        }
    }
}

